#include "entity.h"

void* createData(const void* p_data)
{
	if(p_data==NULL)
		return NULL;

	struct NodeData* _newNode = (struct NodeData*)calloc(sizeof(struct NodeData),1);

	if(_newNode==NULL)
		return NULL;

	_newNode->u = ((struct NodeData*)p_data)->u;
	_newNode->name = strdup((const char*)((struct NodeData*)p_data)->name);

	if(_newNode->name==NULL)
	{
		free(_newNode);
		return NULL;
	}

	return _newNode;
}

int deleteData(const void* to_delete)
{
	free(((struct NodeData*)to_delete)->name);
	return 1;
}


int duplicateNode(Link l1,Link l2)
{
	return 2;
}

int dataCmp(const void* data1, const void* data2)
{
	return (strcmp(((struct NodeData*)data1)->name, ((struct NodeData*)data2)->name));
}

void _printInfo(const void* info)
{
	printf("%s\t%d\n", ((struct NodeData*)info)->name, ((struct NodeData*)info)->u);
}
